﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BugNET.DAL;
using BugNET.Common;
using log4net;
using BugNET.Entities;

namespace BugNET.BLL
{
    public class DashBoardManager
    {
        private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// Get Dashboard- Closure State
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="MileStoneId"></param>
        /// <param name="UserName"></param>
        /// <returns></returns>
        public static List<DashBoard> GetDashBoard_ClosureState(Int32 ProjectId, Int32 MileStoneId, string UserName)
        {
            if (ProjectId <= Globals.NEW_ID) throw (new ArgumentException("The project id is invalid"));
            if (string.IsNullOrEmpty(UserName)) throw (new ArgumentException("The user name cannot be empty or null"));

            var lstDashBoardData = new List<DashBoard>();
            try
            {
                lstDashBoardData = DataProviderManager.Provider.GetDashBoard_ClosureState(ProjectId, MileStoneId, UserName);

            }
            catch (Exception ex)
            {
                Log.Error(LoggingManager.GetErrorMessageResource("GetDashboard Error: Closure State "), ex);
            }
            return lstDashBoardData;
        }

        /// <summary>
        /// Get Dashboard - Issue Status
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="mileStoneId"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <returns></returns>
        public static List<DashBoard> GetDashBoard_Status(int projectId, int mileStoneId, int priorityId, int categoryId, int typeId, DateTime startDate, DateTime endDate)
        {
            if (projectId <= Globals.NEW_ID) throw (new ArgumentException("The project id is invalid"));

            var lstDashBoardData = new List<DashBoard>();
            try
            {
                lstDashBoardData = DataProviderManager.Provider.GetDashBoard_Status(projectId, mileStoneId,priorityId,categoryId,typeId, startDate, endDate);

            }
            catch (Exception ex)
            {
                Log.Error(LoggingManager.GetErrorMessageResource("GetDashboard Error: Status "), ex);
            }
            return lstDashBoardData;
        }


        /// <summary>
        /// Get Dashboard - Issue Status
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <param name="MileStoneId"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <returns></returns>
        public static List<DashBoard> GetDashBoard_Resolution(int projectId, int mileStoneId, int priorityId, int categoryId, int typeId, DateTime startDate, DateTime endDate)
        {
            if (projectId <= Globals.NEW_ID) throw (new ArgumentException("The project id is invalid"));
            

            var lstDashBoardData = new List<DashBoard>();
            try
            {
                lstDashBoardData = DataProviderManager.Provider.GetDashBoard_Resolution(projectId, mileStoneId, priorityId, categoryId, typeId, startDate, endDate);

            }
            catch (Exception ex)
            {
                Log.Error(LoggingManager.GetErrorMessageResource("GetDashboard Error: Resolution "), ex);
            }
            return lstDashBoardData;
        }

    }
}
